<script setup lang="ts">
import metaMask from "./methods/meta-mask.vue"
import networkVersion from "./methods/network-version.vue"
import connectedWallet from "./methods/connected-wallet.vue"
import connectedAccount from "./methods/connected-account.vue"
import getBalance from "./methods/get-balance.vue"
import selectedAddress from "./methods/selected-address.vue"
import sendEth from "./methods/send-eth.vue"


window.ethereum.on("accountsChanged", (accounts: string[]) => {
  uni.showToast({
    title: `账户改变：${accounts.join()}`,
    icon: "none",
    duration: 2000
  })
})

window.ethereum.on("chainChanged", (chainId: string) => {
  uni.showToast({
    title: `链改变：${chainId}`,
    icon: "none",
    duration: 2000
  })
})

</script>

<template>
  <view class="root-container padding-40">
    <metaMask />
    <networkVersion />
    <connectedWallet />
    <connectedAccount />
    <getBalance />
    <selectedAddress />
    <sendEth />
  </view>
</template>

<style lang="scss">
.root-container {
  height: 100vh;
  overflow-y: auto;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
  align-items: center;

  &>view+view {
    margin-top: 24rpx;
  }
}
</style>
